package pl.edu.pw.perg.compinfodb.dao;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.criterion.Restrictions;

import pl.edu.pw.perg.compinfodb.entities.attribute.Attribute;

public class AttributeDAO extends GenericSpringDAO<Attribute> implements IAttributeDAO{

	public static final String ELEMENT = "element";
	public static final String TYPE = "type";

	/* (non-Javadoc)
	 * @see pl.edu.pw.perg.compinfodb.dao.IAttributeDAO#findTypeFields(pl.edu.pw.perg.compinfodb.entities.ElementType)
	 */
	public List<Attribute> findAttributes(String property, Object value) {
		return findByCriteria(Restrictions.eq(property, value));
	}

	@Override
	public void deleteAll() {
	  Query q = getSession().createQuery("delete from Attribute"); 
	  q.executeUpdate();
	}
}
